<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/icon.css"/>">
<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
<title>蒋路的药品详情页面</title>
</head>
<body> 
	<script type="text/javascript">
	function showSelectedDate(rowData) { 
			var pdidyn=$("#elePrint_ic").textbox("getText");
			if(pdidyn==null || pdidyn==""){
				$.messager.confirm("确认", "你还没有输入病人卡号不能开药，是否输入卡号", function (r) {  
					 if (r) {						
						   $("#pdidyn_win").window({'title': "输入病人卡号"});
						   $("#pdidyn_win").window('open');
					 }else{
						 $("#pharStockInfo_tab").datagrid("unselectAll");
					 }
				});
			}else{
				$.messager.confirm("确认", "是否确定开此："+rowData.pharStockMedName, function (r) {  
			        if (r) { 		       	
			        	var price=rowData.pharStockMedName;
			        	$.ajax({
			                type: "Post",
			                url: "tojl_findByPharStockMedName",
			                data: {pharStockMedName:price  },
			                success: function (data) {			                	
			                	 $("#pharStockNumwin").window('open');	                		                	
			                     addRow(data);
			                    
			                }
			            });		        					  
			            return true;  
			        } else{
			        	 $("#pharStockInfo_tab").datagrid("unselectAll");
			        } 
			    });  
			    return false;  
			}		    			
	}  
	
	$(function(){		
		
		$("#pdidyn_save").linkbutton({			
			onClick:function(){					
				var pdidnum=$("#pdidyn_id").textbox("getText");
				if(pdidnum==null || pdidnum==""){
					$.messager.alert("温馨提示"+"卡号异常,请确认卡号！");
				}else{
					var rowIndex=$('#pharStockInfo_tab').datagrid('getRowIndex',$('#pharStockInfo_tab').datagrid('getSelected'));
		        	var rowData = $('#pharStockInfo_tab').datagrid('getData').rows[rowIndex];
					$("#elePrint_ic").textbox("setText",pdidnum);
					$("#pdidyn_win").window('close');
					$.messager.confirm("确认", "是否确定开此："+rowData.pharStockMedName, function (r) {  
				        if (r) { 				        	
				        	var price=rowData.pharStockMedName;
				        	$.ajax({
				                type: "Post",
				                url: "tojl_findByPharStockMedName",
				                data: {pharStockMedName:price  },
				                success: function (data) {			                	
				                	 $("#pharStockNumwin").window('open');	                		                	
				                     addRow(data);			                    
				                }
				            });	
							$("#pdidyn_id").textbox("setText","");
				            return true;  
				        }  else{
				        	$("#pharStockInfo_tab").datagrid("unselectAll");
				        }
				    });  
				    return false;  					
				}				
			}
		});
	
	$("#pdidyn_cancel").linkbutton({
		onClick:function(){	
			$("#pdidyn_id").textbox("setText","");
			 $("#pdidyn_win").window('close'); 	
			 $("#pharStockInfo_tab").datagrid("unselectAll");
		}
	});
		
		$("#pharStock-save").linkbutton({
			onClick:function(){	
				var info="开药成功";
				Queryadc()
				$.messager.alert("温馨提示",info);
				$("#electronicePrint_nember").textbox('clear');
				$("#electronicePrint_money").textbox('clear');
				$("#electronicePrint_price").textbox('clear');
				$("#electronicePrint_Resule").textbox('clear');
				$("#pharStockNumwin").window('close');
			}
		});
		
	   var pharStockMedKind=document.getElementById("pid").getAttribute("pharStockMedKind");
	   var name=document.getElementById("pid").value;
	   if(pharStockMedKind==null ||pharStockMedKind==""){
		   $("#pharStockInfo_tab").datagrid({		   
			   url:'tojl_findByPharStockMedName',
			   queryParams:{
				   pharStockMedName:name
			   }
		   })
	   }else{
		   $("#pharStockInfo_tab").datagrid({		   
			   url:'tojl_findByKindtockMedName',
			   queryParams:{
				   pharStockMedKind:pharStockMedKind
			   }
		   })
	   }
	   
   });	
	</script>
	<input type=text name="pid" id="pid" value="${pid}" pharStockMedKind="${pharStockMedKind}" text="" style="display:none"></input>
	<table id="pharStockInfo_tab" class="easyui-datagrid"				    		 		
				data-options="
				fitColumns:true,
				height:440,											
				url:'',
				border:true,
				pagination:true,
			    checkOnSelect:true,  
            	selectOncheck:true,				
				pageSize: 6,
				onClickRow :function(rowIndex,rowData){  
                 	showSelectedDate(rowData);  
                },  
				pageList:[6,12,18,24]
				">
				<thead>
					<tr>
						<th class="ident" data-options="field:'pharStockId',width:5,checkbox:true">库存编号</th>
						<th class="ident" data-options="field:'pharStockStoreId',width:10">药房</th>
						<th class="ident" data-options="field:'pharStockMedName',width:15,editor:'textbox'">药品</th>
						<th class="ident" data-options="field:'pharStockMedKind',width:10">类型</th>									
						<th class="ident" data-options="field:'pharStockGuige',width:8">规格</th>				
						<th class="ident" data-options="field:'pharStockUnit',width:10">单位</th>								
						<th class="ident" data-options="field:'maiMoney',width:10">金额</th>				
						<th class="ident" data-options="field:'pharStockMedDate',width:9,formatter:function(value){
						        var unixTimestamp = new Date(value);  
						        return unixTimestamp.toLocaleDateString();}">生产日期
						</th> 
						<th class="ident" data-options="field:'pharStockBaozhiqi',width:10,formatter:function(value){
						        var unixTimestamp = new Date(value);  
						        return unixTimestamp.toLocaleDateString();}">保质日期
						</th> 
					</tr>
				</thead>
	 </table>
	 <div id="pharStockNumwin" class="easyui-window"
			style="padding: 10px;line-height: 150%;"
			data-options="
		     width: 450,
		     height:204,
		     closed: true,
		     title:'开药操作'
			">		
					<table>
						<tr>
							<td>
								<div class="item">
									<input id="electronicePrint_nember"   class="easyui-textbox" data-options="label: '数量:', width: 190,validType: ['inputnum'],labelWidth:45">
								</div>
							</td>
							<td>
								<div class="item">
									<input id="electronicePrint_money"   class="easyui-textbox" data-options="label: '金额:', width: 190,labelWidth:45">
								</div>
							</td>								
						</tr>
						<tr>
							<td>
								<div class="item">
									<input id="electronicePrint_price"   class="easyui-textbox" data-options="label: '单价:', width: 190,labelWidth:45">
								</div>
							</td>
							<td>
								<div class="item">
									<input id="electronicePrint_Resule"   class="easyui-textbox" data-options="label: '备注:', width: 190,labelWidth:45">
								</div>
							</td>
							
						</tr>						
						<tr>
							<td>
								<div class="item">
									<a id="pharStock-save" class="easyui-linkbutton">确定</a>
								</div>
							</td>
							<td>
								<div class="item">
									<a id="pharStock-cancel" class="easyui-linkbutton">取消</a>
								</div>
							</td>
						</tr>
					</table>			
		</div>
		 <div id="pdidyn_win" class="easyui-window"style="padding: 10px;line-height: 150%;"data-options="
		     		width: 220,
		     		height: 80,
		     		closed: true
			">			
					<div class="item" >
						<input id="pdidyn_id" name="pdidyn_id" class="easyui-textbox"
							data-options="label: '卡号:', width: 200,labelWidth:40">
					</div>														
					<div>
						<a id="pdidyn_save" class="easyui-linkbutton">确定</a>
						 <a id="pdidyn_cancel" class="easyui-linkbutton">取消</a>
					</div>		
		</div>
</body>
</html>